<?php
/**************************************************
HTML below. No form tag 
(though if you'd like to include another form, 
just close one, and open the new one right after,
like so: </form><form method="post" action="">)
***************************************************/

#Must be included at the top of all mod files.
if(!defined('DREAMSCAPE')){
die('Sorry, but this file cannot be directly viewed.');
}
$size_note = sprintf('<p class="notealert">%s</p>', sprintf(L_SIZE_NOTE,MAX_UPLOAD));
 ?>
<?php
#If you're adding content, use this block
if(ADDING):								
?>
<label for="online"><?php echo L_ONLINE; ?></label><input name="online" class="cBox" type="checkbox" id="online" value="1" checked="checked" /><br />
<label for="title"><?php echo L_PAGE_TITLE; ?></label><input value="<?php echo @$_POST['title']; ?>" name="title" type="text" class="formfields" id="title" size="30" /><input type="hidden" name="aid" value="<?php echo $_SESSION['id']; ?>" /><br />

<label for="descr"><?php echo L_PAGE_BODY; ?></label><textarea name="descr" cols="30" rows="5" id="descr" class="formfields"><?php echo @$_POST['descr']; ?></textarea><br />
<label for="pid"><?php echo L_PAGE_PARENT; ?></label>
<select id="pid" name="pid">
<option value="0"><?php echo L_PAGE_PARENT_NONE; ?></option>
<?php 
get_page_dropdown();
?>
</select><br />
<fieldset id="additionalImages" class="addFiles">
<legend><?php echo L_PAGE_FILES; tooltip(L_PAGE_ADDITIONAL_FILES, L_PAGE_ADDITIONAL_FILES_HELP); ?></legend>
<?php echo $size_note; ?>
<label for="additional_images1"><?php echo L_PAGE_FILE ?> 1</label><input name="additional_images1" type="file" class="formfields" id="additional_images1" size="50" />
<br />
<label for="caption1"><?php echo L_CAPTION ?> 1</label><textarea name="caption[additional_images1]" class="caption" id="caption1"></textarea><br />

</fieldset>
<label for="smilies"><?php echo L_USE_SMILIES ?></label><input name="smilies" class="cBox" type="checkbox" id="smilies" value="1" checked="checked" />
<br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label><input name="comments" class="cBox" type="checkbox" id="comments" value="1" checked="checked" />
<br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
<?php 
$the_module->more_options(L_POST_TIME_ADD, 'doDateTimeForms', 'editDateTimeContainer');
?></div>
<label for="add"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_ADD ?>" />
<?php endif; ?>
<?php
#If you're editing content, use this block
if(EDITING): ?>

		<?php if(EDIT_SINGLE): ?>
		<label for="online"><?php echo L_ONLINE; ?></label>
		<input type="hidden" name="online" value="0" id="" /><input class="cBox" type="checkbox" name="online" value="1" id="online"  <?php echo ($items->online == 1) ? 'checked="checked"' : '';?> /><br />
		<?php echo preview_link(); ?>
<label for="title"><?php echo L_PAGE_TITLE ?></label>
<input name="title" type="text" class="formfields" id="title" value="<?php echo view($items->title);?>" size="30" /><br />


<label for="descr"><?php echo L_PAGE_BODY ?></label><textarea name="descr" cols="30" rows="5" id="descr" class="formfields"><?php echo view($items->descr); ?></textarea><br />

<label><?php echo L_PAGE_PARENT ?></label>
<select id="pid" name="pid">
<option><?php echo L_PAGE_PARENT_NONE ?></option>
<?php 
get_page_dropdown($items->pid);
?>
</select><br />
<label for="dir_title"><?php echo L_PAGE_TEMPLATE_SAFE_TITLE ?></label><input name="dir_title" type="text" class="formfields" id="dir_title" value="<?php echo $items->dirtitle ;?>" size="30" />
<?php tooltip(L_PAGE_TEMPLATE_SAFE_TITLE, sprintf(L_PAGE_TEMPLATE_SAFE_TITLE_HELP, CMS_NAME)); ?>
<fieldset id="additionalImages" class="addFiles">
<legend><?php echo L_PAGE_FILES; tooltip(L_PAGE_ADDITIONAL_FILES, L_PAGE_ADDITIONAL_FILES_HELP); ?></legend>
<?php echo $size_note; ?>
<div id="extraImages"><?php 
$add_images = $images->GetList(array(array('itemid', '=', $item_id)));
$count = count($add_images);
$count++;
foreach($add_images as $ximg){
?>
<div class="imgBox">

<label for="delete_additional<?php echo $ximg->id ?>"><?php echo L_PAGE_ADDITIONAL_FILES_DELETE ?></label><input type="checkbox" id="delete_additional<?php echo $ximg->id ?>" name="delete_additional[]" value="<?php echo $ximg->id ?>" class="xtraImgDelete" />
<img src="funcs/tn.lib.php?image_id=<?php echo $ximg->id ?>&amp;dim=50" title="<?php echo view($ximg->caption); ?>" alt="<?php echo view($ximg->caption) ?>" id="addImg<?php echo $ximg->id ?>" class="thumbnails hasHelp" />
<blockquote class="helpContents" id="addImg<?php echo $ximg->id ?>Help">
<h5><?php echo L_PAGE_FILE_CAPTION ?></h5><?php echo empty($ximg->width) ? "<strong>".L_PAGE_FILE_NAME."</strong> $ximg->image" : ''; ?><?php echo view($ximg->caption) ?></blockquote> </div>
<?php
}
 ?></div><br />
<label for="additional_images1"><?php echo L_PAGE_FILE." $count"; ?></label><input name="additional_images1" type="file" class="formfields" id="additional_images1" size="50" />
<br />
<label for="caption1"><?php echo L_PAGE_FILE_CAPTION." $count"; ?></label><textarea name="caption[additional_images1]" class="caption" id="caption1"></textarea>
<br />
</fieldset>

<label for="smilies"><?php echo L_USE_SMILIES ?></label><input type="hidden" name="smilies" value="0" /><input class="cBox" type="checkbox" name="smilies" value="1" id="smilies"  <?php echo ($items->smilies == 1) ? 'checked="checked"' : '';?><?php echo $items->smilies;?> /><br />
<label for="comments"><?php echo L_ALLOW_COMMENTS; ?></label><input type="hidden" name="comments" value="0" id="" /><input class="cBox" type="checkbox" name="comments" value="1" id="comments"  <?php echo ($items->comments == 1) ? 'checked="checked"' : '';?>  /><br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">

<?php 
$the_module->more_options(
	array(
	L_CLEAN_URL_TITLES => 'doCleanURLTitles'
	)
);
$the_module->more_options(L_SHARE_ITEM, 'doSharing', 'sharing');
$the_module->more_options(L_POST_TIME_EDIT, 'doDateTimeForms', 'editDateTimeContainer');
?>
</div>
<br />
		<label for="edit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_EDIT ?>" />
		<?php elseif(EDIT_LIST): ?>
		<?php $the_module->doSort(); ?>
			<?php
			$itemsList = paginate($itemsList, '', EDIT_LIMIT);
			$numitems = count($itemsList);
			$hasitems = $numitems ? true : false;
			?>
			<div id="itemList">
			<?php 
			foreach($itemsList as $ind => $item):
			$item->title = trim_title($item->title);
			
			$item->descr = trim_excerpt($item->descr);
			$users->Get($item->aid);
			$the_displayname = $users->displayname;
			$the_username = $users->username;
			$has_subcat = ($item->cid != $item->pid && $item->cid != 0) ? true : false;
			if($has_subcat){
				$sections->Get($item->cid);
				$category = $sections->sectionname;
			}
			?>
			<div id="item_<?php echo $item->id ?>">
			<ul>
			 <li class="page_parent"><h1><?php echo $item->title.L_MENU_SEPARATOR ?><a href="<?php echo edit_link($item->id); ?>" title="<?php echo L_EDIT_PAGE; ?>"><?php echo L_EDIT_PAGE; ?></a><?php echo L_MENU_SEPARATOR ?><a href="<?php echo edit_link($item->id); ?>#sharing" title="<?php echo L_SHARE_PAGE ?>" class="shareLink"><?php echo L_SHARE_PAGE ?></a> </h1>
			 <p class="<?php echo ($item->online == 0) ? 'offline' : 'online'; ?>"><?php echo ($item->online == 0) ? L_PAGE_OFFLINE : L_PAGE_ONLINE; ?></p>
			 <h3><?php printf(L_POSTED_BY, $the_displayname, $the_username);?></h3>
			 </li>
			<ul>
<?php 
			get_page_list(0, $item->id);
			?>
</ul>
			</ul>
	 
      
	  <fieldset>
 <label for="item_delete_<?php echo $item->id; ?>"><?php echo L_DELETE_ITEM ?></label><input type="checkbox" name="del[]" value="<?php echo $item->id; ?>" id="item_delete_<?php echo $item->id; ?>" /><br />

</fieldset>
	  </div>
			<?php 
			endforeach;
			?>
			<input type="hidden" value="<?php echo getOption('sortcats'); ?>" id="order_by" />
			</div>

<?php if($hasitems): ?><label for="delete"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_DELETE ?>" />
<?php endif; ?>
		<?php endif; ?>
		
<?php endif; ?>
